<?php
Class C_index extends Cemvc_Control_Base
{
	public function index()
	{
	  print "index";
	  die();
	  /* session_start(); */
	  /* login ? */
	  if ($this->Role == ROLE_GUEST)
	    {
	      /* get user information from users table */
	      $Mdb=M_Qin_Users::getInstance();
	      $arr = $Mdb->where(array("qq_open_id = $_REQUEST['openid']"))->fetchOne();
	      if ($arr && $arr['id'])
		{
		  $this->setRole(ROLE_MEMBER);
		  session_start();
		  $_SESSION["id"] = $arr["id"];
		  $_SESSION["realname"] = $arr["realname"];
		  $_SESSION["openid"] = $arr["qq_open_id"];
		  $_SESSION["openkey"] = $_REQUEST['openkey'];
		  $_SESSION["pf"] = $_REQUEST["pf"];
		  $_SESSION["pfkey"] = $_REQUEST["pfkey"];
		  $_SESSION["gender"] = $arr["gender"];
		  $_SESSION["region_code"] = $arr["region_code"];
		  $_SESSION["day_of_birth"] = $arr["day_of_birth"];
		  $_SESSION["figureurl"] = $arr["figureurl"];
		  $_SESSION["creator"] = $arr["creator"];

		  $this->redirect("/tree/index");
		  return;
		}
	      /* not found user information from the table */
	      /* this is the first time the user visit the site */
	      /* redirect to register page */
	      else
		{
		  $this->assign("WebTitle", "xxxxxxxxxxx");
		  $this->display(); 
		}
	    }
	  else if ($this->Role == ROLE_MEMBER)
	    {
	      $this->redirect("/tree/index");
	    }
	  else if ($this->Role == ROLE_ADMIN)
	    {
	      $this->redirect("/admin/index");
	    }
	  /* print "session: <br/>"; */
	  /* print_r($_SESSION); */
	  /* $this->display(); */

	}
	public function test()
	{
		echo 'test';
	}
	/* public function show() */
	/* { */

	/* 	$Mdb=M_User_Student::getInstance(); */
	/* 	$arr=$Mdb->where(array("id>0"))->limit(3)->fetchAll(); */
	/* 	//echo $Mdb->LastQueryString; */
	/* 	$this->assign("students",$arr);	 */
	/* 	//$Mdb->Limit(3); */
	/* 	//$page_num= $Mdb->count(); */
	/* 	$this->assign("page_str",$Mdb->showPages("",6)); */
	/* 	//$this->assign("page_num",$page_num);	 */
	/* 	$this->display(); */
	/* } */
}
//utf8编码
?>  
